package com.naiterui.ehp.bs.doctor.vo.medicine;

import com.naiterui.ehp.bp.utils.lang.ConfigUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@ApiModel(value = "MedicineCycleVO", description = "用药周期列表")
public class MedicineCycleVO implements Serializable {

    /**
     * 字段或域定义：<code>serialVersionUID</code>
     */
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用药周期字符串：3天、5周等")
    private String cycleStr;

    @ApiModelProperty(value = "周期数")
    private Integer dateNumber;

    @ApiModelProperty(value = "周期单位")
    private String cycleDateUnit;

    @ApiModelProperty(value = "周期值")
    private Integer cycleValue;

    public String getCycleStr() {
        return this.cycleStr;
    }

    public void setCycleStr(String cycleStr) {
        this.cycleStr = cycleStr;
    }

    public Integer getDateNumber() {
        return this.dateNumber;
    }

    public void setDateNumber(Integer dateNumber) {
        this.dateNumber = dateNumber;
    }

    public String getCycleDateUnit() {
        return this.cycleDateUnit;
    }

    public void setCycleDateUnit(String cycleDateUnit) {
        this.cycleDateUnit = cycleDateUnit;
    }

    public Integer getCycleValue() {
        return cycleValue;
    }

    public void setCycleValue(Integer cycleValue) {
        this.cycleValue = cycleValue;
    }

    public static List<MedicineCycleVO> toVOList() {
        List<MedicineCycleVO> list = new ArrayList<>();
        String cycleList = ConfigUtil.getString("init.medicine.cycleList");
        String[] strArray = cycleList.split(",");
        for (String aStrArray : strArray) {
            MedicineCycleVO vo = new MedicineCycleVO();
            String[] str = aStrArray.split("-");
            vo.setCycleStr(str[0]);
            vo.setDateNumber(Integer.parseInt(str[1]));
            vo.setCycleDateUnit(str[2]);
            vo.setCycleValue(Integer.parseInt(str[3]));
            list.add(vo);
        }
        return list;
    }

}
